package com.exchange.controller;

import com.exchange.config.KettleHelper;
import com.exchange.service.TransService;
import com.exchange.utils.result.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.pentaho.di.core.exception.KettleException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
@RequestMapping("/kettle/trans")
@Api(value = "转换管理", tags = "转换管理接口")
public class TransController {

    @Autowired
    private TransService transService;
    @Autowired
    private KettleHelper kettleEnvironments;

    @PostMapping("/executeDataBaseRepTran")
    @ApiOperation("执行转换")
    public CommonResult executeDataBaseRepTran(@RequestParam("transName") String transName) throws KettleException {
        return transService.executeDataBaseRepTran(KettleHelper.getEnviroments().getRepository(), transName, null, null);
    }
}
